" ================================================
" GENERAL VIM SETTINGS START
" ================================================
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
"behave mswin
colorscheme desert

" TAB WIDTH = 4 CHARACTERS
set shiftwidth=4
set tabstop=4

" set automatic indenting
set autoindent

" WRAP Options
set nowrap
" LINEBREAK ONLY FULL WORD, NOT INSIDE WORD
set lbr

" maximise window shortcuts, not the best. Easier to let minibuffexplorer handle
" this
"map <C-J> <C-W>j<C-W>_
"map <C-K> <C-W>k<C-W>_
"map <C-L> <C-W>l <C-W>\|
"map <C-H> <C-W>h <C-W>\|

" MAKE IT EASY TO UPDATE/RELOAD_vimrc
map ,s :source $VIM/_vimrc<Enter>
map ,v :e $VIM/_vimrc<Enter>

" SET THE USER INTERFACE TO MY STYLE
set guioptions=mtrb

" MAXIMIZE VIM UPON STARTUP
au GUIEnter * simalt ~x 

"proper backup settings
set directory=.\\backup,c:\\temp,.
set backupdir=.\\backup,c:\\temp,.

" Virtual edit makes me scroll without being stopped by the selection
"set virtualedit=all
" insert time and date upon F2
map <F2> a<C-R>=strftime("%c")<CR><Esc>
filetype plugin on
filetype indent on 
" ================================================
" GENERAL VIM SETTINGS END
" ================================================










" ===================================== 
" JAVA START
" ===================================== 
" Look for tags file recursively downwards (towards c/d: as opposed to from
" c/d: and also find the tags file for the java source code
set tags=tags;\ c:\Allan\storage\java_src\ibm\java1.3.1\tags
" AUTOSET SOME STUFF IF JAVA FILETYPE
autocmd BufNewFile,BufRead *.java compiler ant 
autocmd BufNewFile,BufRead *.java set ft=java
"try not to use javac together with ant make prg.. causes issues with quickfix
"autocmd BufNewFile,BufRead *.java set makeprg=ant

" automatically map F9 to make for java files
autocmd Filetype java noremap <F9> :w<Enter>:make<Enter>:cw<Enter>
"If Taglist plugin is installed, make it open on right hand side of window
autocmd Filetype java noremap <F12> :TlistToggle<Enter>
" smartindent works nice with java 
autocmd Filetype java setlocal cindent
autocmd Filetype java setlocal omnifunc=javacomplete#Complete 
autocmd Filetype java noremap <F5> :call JavaInsertImport()<CR>

autocmd FileType java source $VIM/vimfiles/ftplugin/jcommenter.vim
autocmd FileType java source $VIM/vimfiles/plugin/java_getset.vim
autocmd FileType java map <M-c> :call JCommentWriter()<CR> 

autocmd Filetype java iab syso System.out.println(

" function for automatically insert java import statements
" it works on current selection 
function! JavaInsertImport() 
  exe "normal mz" 
  let cur_class = expand("<cword>") 

  try 
    if search('^\s*import\s.*\.' . cur_class . '\s*;') > 0 
      throw getline('.') . ": import already exist!" 
    endif 

    wincmd } 
    wincmd P 

    1 
    if search('^\s*public.*\s\%(class\|interface\)\s\+' . cur_class) > 0 
      1 
      if search('^\s*package\s') > 0 
        yank y 
      else 
        throw "Package definition not found!" 
      endif 
    else 
      throw cur_class . ": class not found!" 
    endif 

    wincmd p 
    normal! G 

    " insert after last import or in first line 
    if search('^\s*import\s', 'b') > 0 
      put y 
    else 
      1 
      put! y 
    endif 

    substitute/^\s*package/import/g 
    substitute/\s\+/ /g 
    exe "normal! 2ER." . cur_class . ";\<Esc>lD" 

  catch /.*/ 
    echoerr v:exception 
  finally 
    " wipe preview window (from buffer list) 
    silent! wincmd P 
    if &previewwindow 
      bwipeout 
    endif 
    exe "normal! `z" 
  endtry 
endfunction 
" ===================================== 
" JAVA END
" ===================================== 










" ================================================
" IBM MODELLING STUFF START
" ================================================
autocmd BufNewFile,BufRead *.csv set filetype=csv-general
autocmd BufNewFile,BufRead COMPONENT*_HIERARCHY.csv set filetype=csv-hiearchy
autocmd BufNewFile,BufRead SELECTIVE_ENABLING_*_Group.csv set filetype=csv-selective_enabling
autocmd BufNewFile,BufRead SELECTIVE_MESSAGING_*.csv set filetype=csv-selective_messaging
autocmd BufNewFile,BufRead PROPERTIES_*.csv set filetype=csv-properties
autocmd BufNewFile,BufRead PRODUCTCOMPONENT_*.csv set filetype=csv-product_component
autocmd BufNewFile,BufRead EXPANSION_MATRIX_*.csv set filetype=csv-expansion
autocmd BufNewFile,BufRead DYNAMIC_MinMaxInc_*.csv set filetype=csv-minmax
autocmd BufNewFile,BufRead COMPATIBILITY_FILTERING*.csv set filetype=csv-compability
autocmd BufNewFile,BufRead EXCEPTIONS_*.csv set filetype=csv-exceptions
map ,cf /^\([0-9A-Za-z]*,[A-Z]*,[0-9A-Z]*,[0-9A-Z]*,\)\zs\([0-9]\{4\}\)\ze<Enter>*<C-K>n
" remove name="*" from file
map ,rn :%s/name[ ]\{0,\}=[ ]\{0,\}".\{-\}"[ ]\{0,\}//g<Enter>

" remove embedded newlines from | separated files
" map ,re :%s/\(\|".[^"]*\)\n\(.[^"]*"\)\{-\}/\1\2/g<Enter>
map ,re :g/\|"[^"]*$/j<Enter>

" ================================================
" IBM MODELLING STUFF END
" ================================================










" ================================================
" MISC PLUGIN SETTINGS START
" ================================================
"minimize project window width
let g:proj_window_width=1

" laszlo LZX files are XML files
autocmd BufNewFile,BufRead *.lzx set filetype=xml

" Mini buffer explorer settings
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1 

" txt2tags
autocmd BufNewFile,BufRead *.t2t setlocal ft=txt2tags
autocmd BufNewFile,BufRead *.t2t setlocal spell
autocmd BufNewFile,BufRead *.t2t setlocal wrap
autocmd BufNewFile,BufRead *.t2t setlocal lbr

" txt2tags taglist support
let tlist_txt2tags_settings='txt2tags;d:Titles'
" ================================================
" MISC PLUGIN SETTINGS START
" ================================================
